#include "Configuration.h"
#include <WinSock2.h>
#pragma comment(lib, "winmm.lib")
static void SetSystemTimerResolution(const uint32_t uPeriod)
{
	static UINT timer_period = 0;

	if (uPeriod != timer_period) {
		if (timer_period) {
			timeEndPeriod(timer_period);
		}

		timer_period = uPeriod;

		if (timer_period) {
			timeBeginPeriod(timer_period);
		}
	}
}
void BeginPreciseSleep()
{
	SetSystemTimerResolution(1);
}

void EndPreciseSleep()
{
	SetSystemTimerResolution(0);
}

bool InitializeWinSock()
{
	static bool isInit = false;
	if (!isInit)
	{
		BeginPreciseSleep();
		WSADATA wsaData;
		if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
			return false;
		}
		isInit = true;
	}
	return true;
}